package com.wj.crm.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wj.crm.base.BaseService;
import com.wj.crm.dao.CustomerContactMapper;
import com.wj.crm.dao.CustomerLinkmanMapper;
import com.wj.crm.query.CustomerContactQuery;
import com.wj.crm.query.CustomerLinkmanQuery;
import com.wj.crm.vo.CustomerContact;
import com.wj.crm.vo.CustomerLinkman;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * @author WangJin
 * @version 1.0
 * @date 2022/2/10 18:21
 */
@Service
public class CustomerLinkmanService extends BaseService<CustomerLinkman,Integer> {
    @Autowired
    private CustomerLinkmanMapper customerLinkmanMapper;

    public Map<String, Object> queryCustomerContactByParams(CustomerLinkmanQuery customerLinkmanQuery) {
        Map<String, Object> map = new HashMap<>();

        // 开启分页
        PageHelper.startPage(customerLinkmanQuery.getPage(), customerLinkmanQuery.getLimit());
        // 得到对应分页对象
        PageInfo<CustomerLinkman> pageInfo = new PageInfo<CustomerLinkman>(customerLinkmanMapper.selectByParams(customerLinkmanQuery));

        // 设置map对象
        map.put("code",0);
        map.put("msg","success");
        map.put("count",pageInfo.getTotal());
        // 设置分页好的列表
        map.put("data",pageInfo.getList());

        return map;
    }
}
